package com.e3.basdoc.currency.service;

import java.util.List;

import com.e3.basdoc.currency.model.CurrencyModel;
import com.e3.core.base.ServiceLocator;
import com.e3.core.cache.CacheLoader;

public class CurrencyCacheLoader implements CacheLoader {
	
	private CurrencyQueryService currencyQueryService;
	
	private CurrencyQueryService getCurrencyQueryService(){
		if(currencyQueryService == null){
			currencyQueryService = ServiceLocator.getQueryService(CurrencyQueryService.class);
		}
		return currencyQueryService;
	}

	public void loadeData() throws Exception {
		List<CurrencyModel> models = getCurrencyQueryService().getAllCurrencys();
		if(models==null||models.isEmpty()){
			return;
		}
		for (CurrencyModel model : models) {
			CurrencyCacheManager.INSTANCE.put(model);
		}

	}

}
